<?php
/**
 * 查询角色对应的菜单
 * @author liuhua@leemanpaper.com
 * @version $20180411
 */
$domain = $argv[1];

if (empty($domain)) {
    die('No Params');
}
set_time_limit(0);
require_once(dirname(__FILE__) . '/../../lib/init.php');
cachemgr::init(false);
$_SERVER['HTTP_HOST'] = $domain;

try{
   
    //查询每个角色对应的菜单
    $menus = app::get('desktop')->model('menus');
    $roles = app::get('desktop')->model('roles');
	$roles_data=$roles->getList('*',0,-1);
	foreach ($roles_data as $key => $value) 
	{
		$str=$value['role_name'].'【';
		$workground_data=unserialize($value['workground']);
		foreach ($workground_data as $key1 => $value1) 
		{
			$menus_data=$menus->getList('*',array('permission' =>$value1 ,'menu_type'=>'menu' ),0,-1);
			foreach ($menus_data as $key2 => $value2) 
			{
				$str.=$value2['menu_title'].',';
			}

		}	
		$str.='】';
    	error_log(date('Y-m-d H:i:s') . '发送数据/' . var_export($str, true), 3, PUBLIC_DIR . '/autoqueryallmenu' . date('Y-m-d') . '.log');
	}

}catch (Exception $e) 
{
    error_log(date('Y-m-d H:i:s') . '发送数据/' . var_export($e->getMessage(), true), 3, PUBLIC_DIR . '/autoqueryallmenu' . date('Y-m-d') . '.log');
}


